/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jpa.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author JAVA
 */
@Entity
@Table(name = "Property")
@NamedQueries({
    @NamedQuery(name = "Property.findAll", query = "SELECT p FROM Property p"),
    @NamedQuery(name = "Property.findById", query = "SELECT p FROM Property p WHERE p.id = :id"),
    @NamedQuery(name = "Property.findByCity", query = "SELECT p FROM Property p WHERE p.city = :city"),
    @NamedQuery(name = "Property.findByLocation", query = "SELECT p FROM Property p WHERE p.location = :location"),
    @NamedQuery(name = "Property.findByPrice", query = "SELECT p FROM Property p WHERE p.price = :price"),
    @NamedQuery(name = "Property.findByIsFixed", query = "SELECT p FROM Property p WHERE p.isFixed = :isFixed"),
    @NamedQuery(name = "Property.findByNoOfBedroom", query = "SELECT p FROM Property p WHERE p.noOfBedroom = :noOfBedroom"),
    @NamedQuery(name = "Property.findByNoOfBathroom", query = "SELECT p FROM Property p WHERE p.noOfBathroom = :noOfBathroom"),
    @NamedQuery(name = "Property.findByInteriors", query = "SELECT p FROM Property p WHERE p.interiors = :interiors"),
    @NamedQuery(name = "Property.findByName", query = "SELECT p FROM Property p WHERE p.name = :name"),
    @NamedQuery(name = "Property.findByPhone", query = "SELECT p FROM Property p WHERE p.phone = :phone"),
    @NamedQuery(name = "Property.findByDeposit", query = "SELECT p FROM Property p WHERE p.deposit = :deposit"),
    @NamedQuery(name = "Property.findByRent", query = "SELECT p FROM Property p WHERE p.rent = :rent"),
    @NamedQuery(name = "Property.findByPropertyType", query = "SELECT p FROM Property p WHERE p.propertyType = :propertyType"),
    @NamedQuery(name = "Property.findByAccomodation", query = "SELECT p FROM Property p WHERE p.deposit<=:maxDeposit and p.deposit>=:minDeposit and p.rent<=:maxRent and p.rent>=:minRent and p.city =:city")})
public class Property implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "city")
    private String city;
    @Basic(optional = false)
    @Column(name = "location")
    private String location;
    @Column(name = "price")
    private BigDecimal price;
    @Column(name = "isFixed")
    private Integer isFixed;
    @Column(name = "NoOfBedroom")
    private Integer noOfBedroom;
    @Column(name = "NoOfBathroom")
    private Integer noOfBathroom;
    @Lob
    @Column(name = "ExtraFacilities")
    private String extraFacilities;
    @Lob
    @Column(name = "Transport")
    private String transport;
    @Column(name = "interiors")
    private Integer interiors;
    @Column(name = "name")
    private String name;
    @Column(name = "phone")
    private String phone;
    @Column(name = "deposit")
    private BigDecimal deposit;
    @Column(name = "rent")
    private BigDecimal rent;
    @Column(name = "PropertyType")
    private String propertyType;
    @JoinTable(name = "PropertyUser", joinColumns = {
        @JoinColumn(name = "propertyId", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "userName", referencedColumnName = "userName")})
    @ManyToMany
    private Collection<User> userCollection;
    @JoinColumn(name = "TypeId", referencedColumnName = "id")
    @ManyToOne
    private TypeOfProperty typeOfProperty;
    @JoinColumn(name = "paymentId", referencedColumnName = "id")
    @ManyToOne
    private MethodPayment methodPayment;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "property")
    private Collection<ImageProperty> imagePropertyCollection;

    public Property() {
    }

    public Property(Integer id) {
        this.id = id;
    }

    public Property(Integer id, String city, String location) {
        this.id = id;
        this.city = city;
        this.location = location;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getIsFixed() {
        return isFixed;
    }

    public void setIsFixed(Integer isFixed) {
        this.isFixed = isFixed;
    }

    public Integer getNoOfBedroom() {
        return noOfBedroom;
    }

    public void setNoOfBedroom(Integer noOfBedroom) {
        this.noOfBedroom = noOfBedroom;
    }

    public Integer getNoOfBathroom() {
        return noOfBathroom;
    }

    public void setNoOfBathroom(Integer noOfBathroom) {
        this.noOfBathroom = noOfBathroom;
    }

    public String getExtraFacilities() {
        return extraFacilities;
    }

    public void setExtraFacilities(String extraFacilities) {
        this.extraFacilities = extraFacilities;
    }

    public String getTransport() {
        return transport;
    }

    public void setTransport(String transport) {
        this.transport = transport;
    }

    public Integer getInteriors() {
        return interiors;
    }

    public void setInteriors(Integer interiors) {
        this.interiors = interiors;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public BigDecimal getDeposit() {
        return deposit;
    }

    public void setDeposit(BigDecimal deposit) {
        this.deposit = deposit;
    }

    public BigDecimal getRent() {
        return rent;
    }

    public void setRent(BigDecimal rent) {
        this.rent = rent;
    }

    public String getPropertyType() {
        return propertyType;
    }

    public void setPropertyType(String propertyType) {
        this.propertyType = propertyType;
    }

    public Collection<User> getUserCollection() {
        return userCollection;
    }

    public void setUserCollection(Collection<User> userCollection) {
        this.userCollection = userCollection;
    }

    public TypeOfProperty getTypeOfProperty() {
        return typeOfProperty;
    }

    public void setTypeOfProperty(TypeOfProperty typeOfProperty) {
        this.typeOfProperty = typeOfProperty;
    }

    public MethodPayment getMethodPayment() {
        return methodPayment;
    }

    public void setMethodPayment(MethodPayment methodPayment) {
        this.methodPayment = methodPayment;
    }

    public Collection<ImageProperty> getImagePropertyCollection() {
        return imagePropertyCollection;
    }

    public void setImagePropertyCollection(Collection<ImageProperty> imagePropertyCollection) {
        this.imagePropertyCollection = imagePropertyCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Property)) {
            return false;
        }
        Property other = (Property) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jpa.entities.Property[id=" + id + "]";
    }

}
